package com.itheima.a03threadcase3;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class ThreadDemo1 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        //多线程的实现方式3 Callable

        //创建Callable接口的实现类对象 多线程要执行的任务
        MyCallable mc = new MyCallable();

        //创建FutureTask对象 管理多线程运行的结果
        FutureTask<String> ft = new FutureTask<>(mc);

        //创建线程对象
        Thread t = new Thread(ft);

        //启动线程
        t.start();

        //获取多线程运行的结果
        String s = ft.get();
        System.out.println(s);

    }
}
